# -*-perl-*-
# APA: Add SystemLiteral to identify the canonical DTD.
# [Definition:] The SystemLiteral is called the entity's system
# identifier. It is a URI, which may be used to retrieve the entity.
# See http://www.xml.com/axml/target.html#NT-ExternalID
$DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN" "http://www.w3.org/TR/html32/loose.dtd">';

$FRAMESET_DOCTYPE = $DOCTYPE;

$BODYTEXT = 'bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"';
# this controls the pre style for menus
$MENU_PRE_STYLE = '';

$TOC_LIST_STYLE ='';

$USE_ISO = 0;
$MENU_SYMBOL = '*';

# This lines are inserted before and after the shortcontents 
$BEFORE_OVERVIEW = "";
$AFTER_OVERVIEW = '';

# This lines are inserted before and after the contents 
$BEFORE_TOC_LINES = "";
$AFTER_TOC_LINES = '';

# html version for latex2html
$L2H_HTML_VERSION = "3.2";

# no css
$CSS_LINES = "";
%css_map = ();

$things_map{'oe'} = '&#156;';
$things_map{'OE'} = '&#140;';
$things_map{'dots'} = '<small>...</small>';
$things_map{'enddots'} = '<small>....</small>';
$things_map{'euro'} = 'Euro';
$style_map{'sansserif'} = {};

# formatting functions

$summary_letter    = \&t2h_html32_summary_letter;
$protect_text      = \&t2h_html32_protect_text;
$heading           = \&t2h_html32_heading;
$preformatted      = \&t2h_html32_preformatted;
$raw               = \&t2h_html32_raw;
$menu              = \&t2h_html32_menu;
$foot_section      = \&t2h_html32_foot_section;
$cartouche         = \&t2h_html32_cartouche;
$listoffloats      = \&t2h_html32_listoffloats;
$float             = \&t2h_html32_float;

# &quot; is not in html 3.2
sub t2h_html32_protect_text($)
{
   my $text = shift;
   $text =~ s/&/&amp;/g;
   $text =~ s/</&lt;/g;
   $text =~ s/>/&gt;/g;
   #$text =~ s/\"/&quot;/g;
   return $text;
}

# a preformatted section
sub t2h_html32_preformatted($$$)
{
    my $text = shift;
    my $pre_style = shift;
    my $class = shift;

    return '' if ($text eq '');
    return "<pre>$text</pre>";
}

# a heading for an element
sub t2h_html32_heading($)
{
    my $element = shift;
    my $level = 3;
    if (!$element->{'node'})
    {
        $level = $element->{'level'};
    }
    $level = 1 if ($level == 0);
    my $text = $element->{'text'};
    if (!$element->{'node'} and (!$NUMBER_SECTIONS))
    {
        $text = $element->{'name'};
    }
    return '' if ($text !~ /\S/);
    if (defined($element->{'tocid'}) and $TOC_LINKS)
    {
         $text = &$anchor ('', "$Texi2HTML::THISDOC{'toc_file'}#$element->{'tocid'}", $text);
    }
    return "<h$level> $text </h$level>\n";
}

# formatting of raw regions
# ih L2H is true another mechanism is used for tex
sub t2h_html32_raw($$)
{
    my $style = shift;
    my $text = shift;
    if ($style eq 'verbatim' or $style eq 'tex')
    {
        return "<pre>" . &$protect_text($text) . '</pre>';
    }
    elsif ($style eq 'html')
    {
        return $text;
    }
    else
    {
        warn "$WARN (bug) unknown style $style\n";
        return &$protect_text($text);
    }
}

# a whole menu
sub t2h_html32_menu($)
{
    my $text = shift;
    if ($text =~ /\S/)
    {
        return "<table border=\"0\" cellspacing=\"0\">\n" 
        . $text . "</table>\n";
    }
}

# a simple menu entry ref in case we aren't in a standard menu context
sub t2h_html32_foot_section($)
{
    my $lines = shift;
    unshift (@$lines, "<hr>\n", "<h3>Footnotes</h3>\n");
    return $lines; 
}

# a cartouche
sub t2h_html32_cartouche($)
{
    my $text = shift;

    if ($text =~ /\S/)
    {
        return "<table border=\"1\"><tr><td>\n" . $text . "</td></tr></table>\n";
    }
    return '';
}


# no style
sub t2h_html32_summary_letter($$$)
{
   my $letter = shift;
   my $file = shift;
   my $identifier = shift;
   return &$anchor('', $file . '#' . $identifier, '<b>' . &$protect_text($letter) . '</b>');
}

sub t2h_html32_float($$$$$)
{
    my $text = shift;
    my $float = shift;
    my $caption = shift;
    my $shortcaption = shift;
    
    my $label = '';
    if (exists($float->{'id'}))
    {
        $label = &$anchor($float->{'id'});
    }
    my $caption_text = '';
    
    if (defined($float->{'caption_texi'}))
    {
         $caption_text = $caption;
    }
    elsif (defined($float->{'shortcaption_texi'}))
    {
         $caption_text = $shortcaption;
    }
    elsif (defined($caption))
    {
         $caption_text = $caption;
    }
    
    return "$label\n" . $text . $caption_text;
}

sub t2h_html32_listoffloats($$$)
{
    my $style_texi = shift;
    my $style = shift;
    my $float_entries = shift;

    my $result = "<dl>\n" ;
    foreach my $float_entry (@$float_entries)
    {
         $result .= $float_entry;
    }
    return $result . "</dl>\n";
} 


